<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta charset="UTF-8">
    <title>短网址生成</title>
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
    <script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container text-center">
    <h3>生成短网址</h3>
</div>
<div class="container">
    <div class="form-group">
        <label for="ori">原网址</label>
        <input type="text" id="ori" class="form-control">
    </div>
    <div class="form-group" id="showori"></div>
    <button type="button" id="btn" class="btn btn-default">生成短网址</button>
</div>
<script>
    $('#btn').on('click', function () {
        var ori = $('#ori').val();
        if(ori == ''){
            alert('网址要填写！');
            return;
        }
        $.post('api.php',{ori:ori},function (data) {
           $('#showori').html(data);
        });

    });
</script>
</body>
</html>